home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacPeople 2001 June 15
/
MACPEOPLE-2001-06-15.ISO.7z
/
MACPEOPLE-2001-06-15.ISO
/
連載データ
/
OS X情報局
/
x-assist-03j.sit
/
X-Assist Japanese.dmg
/
X-Assist プラグイン SDK
/
SetVolume Example
/
XAPlugin.m
< prev
Wrap
Text File
|
2001-04-17
|
3KB
|
127 lines
//
// Plugin.m
// MyPlugin
//
// Created by rosst on Fri Apr 13 2001.
// Copyright (c) 2001 __CompanyName__. All rights reserved.
//
#import "XAPlugin.h"
#include <Carbon/Carbon.h>
// ============================
// == Change "SetVolume" below to your plugin name.
// == Once you build the plugin, place it into the "X-Assist Plugins" folder
// == and everything should just load.
// == NOTE: you MUST use a unique name, otherwise the conflicting plugins
// == will NOT load.
// ============================
@implementation SetVolume
- (id)init
{
// init plugin internals...
mPluginMenuItem = NULL;
// ===============================
// Your Initialization code here...
// ===============================
GetSysBeepVolume(&mCurVolume);
// END Initialization code.
return self;
}
- (void)shutdownPlugin
{
// ===============================
// Your Shutdown code here...
// ===============================
if (mPluginMenuItem != NULL)
[mPluginMenuItem release];
}
// Required Plugin Routines
- (NSMenuItem*)getMenuItem
{
if (mPluginMenuItem == NULL)
{
mPluginMenuItem = [[NSMenuItem alloc] init];
// ===============================
// Setup our Menu item to our specifications...
// ===============================
{
NSMenu* subMenu = [[NSMenu alloc] init];
NSMenuItem* anItem;
int counter;
[mPluginMenuItem setTitle:@"Set Volume"];
// you could add your own menu item icon too...
// [mPluginMenuItem setImage: myNSImage /* (NSImage *)menuImage */];
for (counter = 0; counter < 11; counter++)
{
anItem = [[NSMenuItem alloc] init];
[anItem setTitle:[NSString stringWithFormat:@"%d", counter]];
[anItem setEnabled:YES];
[anItem setAction:@selector(DoSetVolumeTo:) ];
[anItem setTarget:self];
[subMenu addItem:anItem];
[anItem autorelease];
}
[mPluginMenuItem setSubmenu:subMenu];
}
// END setup.
// ===============================
}
return mPluginMenuItem;
}
// items below are for future use.
- (int)getMenuItemInsertLocation
{
return 0; // default location.
}
- (int)getPluginAPIVersion
{
return 1;
}
// return info & copyright etc.
- (NSString*)getPluginDescription
{
return @"SetVolume v0.1¥r¥rSets the SysBeep volume.";
}
// put up config window...
- (void)doConfigurePlugin
{
}
// User routines
- (IBAction)DoSetVolumeTo:(id)sender
{
mCurVolume = atoi([[sender title] cString]);
SetSysBeepVolume((long) (25.6 * mCurVolume));
SetDefaultOutputVolume((long) (25.6 * mCurVolume));
SysBeep(30);
}
@end